<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回当前缓存的到期时间</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.session-cache-expire" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">session_cache_expire</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">session_cache_expire</span> &mdash; <span class="dc-title">返回当前缓存的到期时间</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.session-cache-expire-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>session_cache_expire</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$new_cache_expire</code></span>
  ] ) : <span class="type">int</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>session_cache_expire()</strong></span> 返回
   <em>session.cache_expire</em> 的设定值。 
  </p>
  <p class="para">
   请求开始的时候，缓存到期时间会被重置为 180，并且保存在
   <a href="session.configuration.html#ini.session.cache-expire" class="link">session.cache_expire</a> 配置项中。
   因此，针对每个请求，需要在 <span class="function"><a href="session_start.html" class="function">session_start()</a></span> 函数调用之前
   调用 <span class="function"><strong>session_cache_expire()</strong></span> 来设置缓存到期时间。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.session-cache-expire-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">new_cache_expire</code></dt>

     <dd>

      <p class="para">
       如果给定 <code class="parameter">new_cache_expire</code> ，就使用
       <code class="parameter">new_cache_expire</code> 的值设置当前缓存到期时间。
      </p>
      <p class="para">
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <span class="simpara">
         仅在 <em>session.cache_limiter</em> 的设置值
         <em class="emphasis">不是</em> <em>nocache</em> 的时候，
         才可以设置 <code class="parameter">new_cache_expire</code> 参数。
        </span>
       </p></blockquote>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.session-cache-expire-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回 <em>session.cache_expire</em> 的当前设置值，
   以分钟为单位，默认值是 180 （分钟）。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.session-cache-expire-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5829">
    <p><strong>Example #1 <span class="function"><strong>session_cache_expire()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;设置缓存限制为&nbsp;“private”&nbsp;*/<br /><br /></span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">(</span><span style="color: #DD0000">'private'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_limiter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/*&nbsp;设置缓存过期时间为&nbsp;30&nbsp;分钟&nbsp;*/<br /></span><span style="color: #0000BB">session_cache_expire</span><span style="color: #007700">(</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_expire&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">session_cache_expire</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/*&nbsp;开始会话&nbsp;*/<br /><br /></span><span style="color: #0000BB">session_start</span><span style="color: #007700">();<br /><br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;cache&nbsp;limiter&nbsp;is&nbsp;now&nbsp;set&nbsp;to&nbsp;</span><span style="color: #0000BB">$cache_limiter</span><span style="color: #DD0000">&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;cached&nbsp;session&nbsp;pages&nbsp;expire&nbsp;after&nbsp;</span><span style="color: #0000BB">$cache_expire</span><span style="color: #DD0000">&nbsp;minutes"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.session-cache-expire-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="session.configuration.html#ini.session.cache-expire" class="link">session.cache_expire</a></li>
    <li class="member"><a href="session.configuration.html#ini.session.cache-limiter" class="link">session.cache_limiter</a></li>
    <li class="member"><span class="function"><a href="session_cache_limiter.html" class="function" rel="rdfs-seeAlso">session_cache_limiter()</a> - 读取/设置缓存限制器</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>